<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>订单修改</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">订单id</label>
        <div class="layui-input-block">
            <input type="text" name="id"  id="id" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">订单编号</label>
        <div class="layui-input-block">
            <input type="text" name="orderNumber"  id="orderNumber" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">用户名</label>
        <div class="layui-input-block">
            <input type="text" id="userName" name="userName"  value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户地址</label>
        <div class="layui-input-block">
            <input type="text" name="userArea" id="userArea"  readonly value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系电话</label>
        <div class="layui-input-block">
            <input type="text" name="userPhone" id="userPhone" readonly  value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">预约时间</label>
        <div class="layui-input-block">
            <input type="text" name="orderVisitTime" id="orderVisitTime" readonly  value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品类别</label>
        <div class="layui-input-block">
            <input type="text" name="payProductType" id="payProductType" readonly  value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">订单金额</label>
        <div class="layui-input-block">
            <input type="text" name="payOrderMoney" id="payOrderMoney" readonly  value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">支付时间</label>
        <div class="layui-input-block">
            <input type="text" name="payTime" id="payTime" readonly  value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">预估重量</label>
        <div class="layui-input-block">
            <input type="text" name="payForecastWeight" id="payForecastWeight" readonly  value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">骑手账号</label>
        <div class="layui-input-block">
            <input type="text" name="horsemanAccount" id="horsemanAccount" readonly  value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">骑手姓名</label>
        <div class="layui-input-block">
            <input type="text" name="horsemanName" id="horsemanName" readonly  value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">骑手到达时间</label>
        <div class="layui-input-block">
            <input type="text" name="horsemanArrivalTime" id="horsemanArrivalTime" readonly  value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">计量时间</label>
        <div class="layui-input-block">
            <input type="text" name="horsemanMeasureTime" id="horsemanMeasureTime" readonly  value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">区域</label>
        <div class="layui-input-block">
            <input type="text" name="county" id="county" readonly  value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">订单状态</label>
        <div class="layui-input-block">
            <form class="layui-form" id="from1">
                <select name="orderState" id="orderState" lay-filter="orderState" lay-verify="required" lay-search>
                    <option value="">请选择</option>
                    <option value="待派单">待派单</option>
                    <option value="待接单">待接单</option>
                    <option value="进行中">进行中</option>
                    <option value="待支付">待支付</option>
                    <option value="已完成">已完成</option>
                    <option value="异常订单">异常订单</option>
                    <option value="已打包">已打包</option>
                    <option value="已评价">已评价</option>
                </select>
            </form>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">图片</label>
        <div class="layui-input-block">
           <img src="" id="orderImg" height="300" width="600">
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认修改</button>
        </div>
    </div>
</div>
</div>
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="../../lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            //系统公告
            console.log(JSON.stringify(data.field))
            $.ajax({
                type: "post",
                url: "../order/updateorder",
                dataType: "json",
                contentType:'application/json;charset=utf-8',
                data:JSON.stringify(data.field),
                success: function (result) {
                    if(result.result=="success"){
                        layer.alert('修改成功', {icon: 1});
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                        //parent.$("#shousuobtn",parent.document).trigger('click');	//子页面局部刷新父页面事件
                        window.parent.document.getElementById("shousuobtn").click();
                    }
                    console.info(result);
                },
                error: function () {
                    console.log("网络出错！请重新连接")
                }
            });

            return false;
        });

    });

    $(document).ready(function(){
        //id查询赋值
        $.ajax({
            type: "get",
            url: "/order/idquerysession",
            dataType: "json",
            success: function (result) {
               console.log(result);
               //$("#orderNumber").attr("value",result.order.orderNumber)
                $("#id").attr("value",result.order.id);
                $("#orderNumber").val(result.order.orderNumber);
                $("#userName").attr("value",result.order.userName);
                $("#userArea").attr("value",result.order.userArea);
                $("#userPhone").attr("value",result.order.userPhone);
                $("#orderVisitTime").attr("value",result.order.orderVisitTime);
                $("#payProductType").attr("value",result.order.payProductType);
                $("#payOrderMoney").attr("value",result.order.payOrderMoney);
                $("#payTime").attr("value",result.order.payTime);
                $("#payForecastWeight").attr("value",result.order.payForecastWeight);
                $("#horsemanAccount").attr("value",result.order.horsemanAccount);
                $("#horsemanName").attr("value",result.order.horsemanName);
                $("#horsemanArrivalTime").attr("value",result.order.horsemanArrivalTime);
                $("#horsemanMeasureTime").attr("value",result.order.horsemanMeasureTime);
                $("#county").attr("value",result.order.county);
                var img=result.order.orderImg;
                 var index=img.lastIndexOf("\,");
                 img=img.substring(index+1,img.length);
                $('#orderImg').attr("src",img);
            },
            error: function () {
                console.log("网络出错！请重新连接")
            }
        });
    });
</script>
</body>
</html>